import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)


export const constantRouterMap = [
  {
    path: '/',
    name: 'index',
    component: () => import('@/views/home/home'),
    redirect: '/index',
    children: [
      {path: '/index', name: 'index', component: () => import('@/views/home/index')},
      {path: '/product/:id', component: () => import('@/views/product/product')},
    ],
    hidden: true
  },
  {path: '/login', name: 'login', component: () => import('@/views/login'), hidden: true},
  {path: '/detail/:id', component: () => import('@/views/detail/detail'), hidden: true},
  {path: '/cart',name:'cart', component: () => import('@/views/cart/cart'), hidden: true},

  {
    path: '/order',
    redirect: '/order',//重定向
    component: () => import('@/views/order/order'),
    children: [
      {path: 'list', component: () => import('@/views/order/orderList')},
      {path: 'confirm',name: 'order-confirm', component: () => import('@/views/order/orderConfirm')},
      {path: 'pay', component: () => import('@/views/order/orderPay')},
      {path: 'aliPay', component: () => import('@/views/order/aliPay')},
    ]
  },

  /*
  {
    path: '/subject',
    component: Layout,//布局
    redirect: '/subject/index',//重定向
    name: '课程分类管理',
    meta: {title: '课程分类管理', icon: 'nested'},
    children: [
      {
        path: 'index',
        name: '课程分类列表',
        component: () => import('@/views/edu/subject/index'),
        meta: {title: '课程分类列表', icon: 'table'}
      },
      {
        path: 'save',
        name: '添加课程分类',
        component: () => import('@/views/edu/subject/save'),
        meta: {title: '添加课程分类', icon: 'tree'}
      },
      {
        path: 'edit/:id',
        name: '课程分类信息修改',
        component: () => import('@/views/edu/subject/save'),
        meta: {title: '课程分类信息修改', icon: 'tree'},
        hidden: true
      }
    ]
  },*/

  {path: '*', redirect: '/404', hidden: true}
]

export default new Router({
  mode: 'history', //后端支持可开
  //scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})
